﻿using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VisionCloud.Core.Model.Ms;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.Data;
using VisionCloud.Domain.DtoModel.MiniApp;
using VisionCloud.Domain.DtoModel.Ms;

namespace VisionCloud.Domain.Repository.Interface.Ms
{
    public interface IMsTaskRepository : IBaseRepository<MsTask>
    {
        /// <summary>
        /// 查询小程序创建的任务列表
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="userId">任务创建者</param>
        /// <param name="projectStandardId">工程阶段Id</param>
        /// <returns></returns>
        ValueTask<List<TaskInfoResponseDto>> GetTaskListAsync(QueryTaskRequestDto dto, Guid userId, Guid? projectStandardId);

        Task<ApiPageResult> GetPage(TaskCm condition);

        Task<List<ProjectRobot>> GetProjectRobot(Guid projectId);

        Task<List<ProjectMember>> GetProjectMember(Guid projectId);

        Task<List<SelectItem>> GetUserProject();

        Task<List<ProjectHouseMap>> GetProjectHouseMap(Guid projectId);

        Task<TaskSfm> GetModel(Guid taskId, string houseTypeName = null);

        Task<TaskSfm> GetModel(MsTask model);

        /// <summary>
        /// 获取匹配任务名称前缀的最大任务编号
        /// </summary>
        /// <param name="taskNamePrex"></param>
        /// <returns></returns>
        Task<int?> GetNextTaskNameNo(string taskNamePrex);

        Task<int?> GetNextTaskNameNo(Guid projectId, string build, string floor, string houseHolds, string taskProperty);

        /// <summary>
        /// 根据任务Id获取非跟踪级别对象
        /// </summary>
        /// <param name="taskId">任务Id</param>
        /// <returns></returns>
        Task<MsTask> GetMsTask(Guid taskId);

        /// <summary>
        /// 根据任务Id取任务站点
        /// </summary>
        /// <param name="taskId">任务Id</param>
        /// <returns></returns>
        Task<List<MeasurePoints>> GetTaskPoints(Guid taskId, Guid houseMapId);

        Task<ProjectHouseMap> GetProjectHouseMapModel(Guid projectId, Guid houseMapId);

        /// <summary>
        /// 同步任务数据
        /// </summary>
        /// <param name="taskId">任务Id</param>
        /// <returns></returns>
        Task<MsTask> GetTaskData(Guid taskId);

        /// <summary>
        /// 获取用户项目并设置缓存
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<List<Guid>> GetUserProjects(Guid userId);

        /// <summary>
        /// 删除项目缓存
        /// </summary>
        void RemoveUserProjects();

        /// <summary>
        /// 获取户型图
        /// </summary>
        /// <returns></returns>
        string GetHouseMapImage(Guid taskId);

        /// <summary>
        /// 获取任务相关的信息
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        Task<MsTaskStatisticsInfo> GetTaskStatisticsInfoAsync(Guid taskId);

        /// <summary>
        /// 获取分户汇总信息
        /// </summary>
        /// <param name="taskId">任务Id</param>
        /// <returns></returns>
        ValueTask<MsApartmentSunmaryInfoDto> GetApartmentSunmaryInfo(Guid taskId);

        /// <summary>
        /// 更新任务状态
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ValueTask<bool> UpdateTaskStatusAsync(UpdateTaskStatusRequestDto dto);

        /// <summary>
        /// 获取任务基本信息
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        ValueTask<TaskInfoBaseDto> GetBaseInfoAsync(Guid taskId);
    }
}